Type Definitions
The following definitions are providing types for sort and filter blocks.
The following type definitions are available globally.
-
This type if being used when we need a boolean information of the elements of a collection, eg. filter or contains
Declaration
Objective-C
typedef BOOL (^FunkyFilterPredicate)(id)
Swift
typealias FunkyFilterPredicate = (Any?) -> Bool
-
This type is used when filtering collections with
bucket sort
Declaration
Objective-C
typedef BOOL (^FunkySortingBucketFilterBlock)(id)
Swift
typealias FunkySortingBucketFilterBlock = (Any?) -> Bool
-
This is a protocol for comparing objects, but we’re only interested in their asending or descending information. It is usually used when comparing numbers in an array, like
return obj1 < obj2
to have an ascending collectionDeclaration
Objective-C
typedef BOOL (^FunkySortBoolComparableBlock)(id, id)
Swift
typealias FunkySortBoolComparableBlock = (Any?, Any?) -> Bool
-
This is a protocol for comparing objects via a mapped value. In case of complex objects you can return a sub-property which implements the
-compare:
method, so the collection will be sorted by that computed property.Declaration
Objective-C
typedef id (^FunkySortComparablePropertyProviderBlock)(id)
Swift
typealias FunkySortComparablePropertyProviderBlock = (Any?) -> Any?